Ext.define('App.controller.club.ClubViewController', {
	extend : 'Ext.app.ViewController',
	alias : 'controller.clubViewController',
	menu : Ext.widget('menu'),
	control : {
		'clubView clubList' : {
			beforerender : function(grid) {
				var buttons = {
					'bs/club/saveClub' : function(permit) {
						BaseUtil.createView('club.ClubWindow',permit,{storeId:'club.ClubStore'}).show();
					}
				};
				BaseUtil.createPermitTbar(grid, buttons);
			},
			itemcontextmenu : function(view, record, item, index, e) {
				var id = record.get('id');
				var menuitems = {
					'bs/club/updateClub' : function(permit) {
						var win = BaseUtil.createView('club.ClubWindow',permit,{storeId:'club.ClubStore'});

                        var imgBtn = win.down('[name=btn1]');
                        var imgPath=win.down("[name=clubImgPath]");
                        var img=win.down("[name=clubImgs]");
                        imgBtn.setVisible(true);
                        imgPath.setVisible(true);
                        img.setVisible(false);
                        if(imgPath!='') {
                            img.setDisabled(true);
                        }

						win.down('form').loadRecord(record);
						win.show();
					}
				};
				var status = record.get('status'),store = Ext.StoreMgr.get('club.ClubStore');
				if(status === StatusEnum.DELETE.getValue()){
					menuitems['bs/club/recover'] = function(permit) {
						BaseUtil.statusConfirm('确认恢复此记录吗?',permit.url,id,store);
					}
				}else{
					menuitems['bs/club/removeClub'] = function(permit) {
						BaseUtil.statusConfirm('确认删除此记录吗?',permit.url,id,store);
					}
				}
				BaseUtil.createPermitMenu(view, this.menu, e, menuitems);
			},
			render : function() {
				BaseUtil.loadStore(Ext.StoreMgr.get('club.ClubStore'),Ext.getCmp('clubView').down('clubSearch form').getForm().getFieldValues());
			}
		},
		'clubView clubSearch [action=search] ' : {
			click : function() {
				BaseUtil.loadStore(Ext.StoreMgr.get('club.ClubStore'),Ext.getCmp('clubView').down('clubSearch form').getForm().getFieldValues());
			}
		}
	}
});